Exercise 2

Zhipei (Kim) Wang

A centered still figure

My cat listening to me practicing the violin

A 2-column slide

My cat listening to me practicing the violin

The above figure is left-aligned
The caption is also left-aligned

My cat listening to me practicing the violin

The above figure is centered
The caption is also centered

A looping gif with executed, but not displayed r-code

r-code, displayed but not executed

library(magick)
gif <- image_read("wink.gif")
image_animate(gif, loop = 10)

An interactive plot

library(plotly)
library(gapminder)
library(ggplot2)

p <- gapminder %>%
  filter(year==1987 & continent == "Asia") %>%
  ggplot( aes(gdpPercap, lifeExp, size = pop, color=country)) +
  geom_point() +
  labs(x = "GDP per capita", y = "Life expectation") + 
  theme_bw()

ggplotly(p)

r-code, cached and labeled

gapminder %>%
  filter(year == 1987) %>%
  ggplot( aes(gdpPercap, lifeExp, col = continent)) +
  geom_point() +
  labs(x = "GDP per capita", y = "Life expectation") + 
  theme_bw()

An interactive table

library(DT)
gapminder %>% 
  datatable(options = list(pageLength = 10))

An aligned multi-row equation

The spike-and-slab prior (Mitchell and Beauchamp 1988; George and McCulloch 1993) falls into the category of discrete mixture priors. Such a prior can often be written as a mixture of two normal distributions (Piironen, Paasiniemi, and Vehtari 2020): \[ \begin{aligned} \beta_j \mid \lambda_j, c, \varepsilon &\sim \lambda_j \text{N}(0, c^2) + (1 - \lambda_j) \text{N}(0, \varepsilon^2), \nonumber \\ \lambda_j \mid \pi &\sim \text{Bernoulli}(\pi), \quad j = 1, \dots, p. \end{aligned} \]

An renv reproducible enviroment

library(renv)
renv::snapshot()
- The lockfile is already up to date.

References

George, Edward, and Robert McCulloch. 1993. “Variable Selection via Gibbs Sampling.” Journal of The American Statistical Association - J AMER STATIST ASSN 88 (September): 881–89. https://doi.org/10.1080/01621459.1993.10476353.
Mitchell, T. J., and J. J. Beauchamp. 1988. “Bayesian Variable Selection in Linear Regression.” Journal of the American Statistical Association 83 (404): 1023–32. https://doi.org/10.2307/2290129.
Piironen, Juho, Markus Paasiniemi, and Aki Vehtari. 2020. “Projective Inference in High-Dimensional Problems: Prediction and Feature Selection.” Electronic Journal of Statistics 14 (1). https://doi.org/10.1214/20-EJS1711.